// any
let foo;

// foo、bar 均为 any
function func(foo: any, bar: any) { }

// 被标记为 any 类型的变量可以拥有任意类型的值
let anyVar: any = "linbudu";

anyVar = false;
anyVar = "linbudu";
anyVar = {
  site: "juejin"
};
anyVar = () => { }

// 标记为具体类型的变量也可以接受任何 any 类型的值
const val1: string = anyVar;
const val2: number = anyVar;
const val3: () => {} = anyVar;
const val4: {} = anyVar;

console.log("val1__", val1);

let anyVar1: any = { foo: {} };

// anyVar1.foo.bar.baz();
// anyVar1[0][1][2].prop1;

let unknownVar: unknown = "linbudu";

unknownVar = false;
unknownVar = 'linbudu'
unknownVar = {
  site: 'juejin'
}

unknownVar = () => { }

// const val1_1: string = unknownVar; // Error
// const val2_1: number = unknownVar; // Error
// const val3_1: () => {} = unknownVar; // Error
// const val4_1: {} = unknownVar; // Error

const val5_1: any = unknownVar;
const val6_1: unknown = unknownVar;

//简单地说，any 放弃了所有的类型检查，而 unknown 并没有。这一点也体现在对 unknown 类型的变量进行属性访问时：

let unknownVar1: unknown;

// unknownVar1.foo(); // 报错：对象类型为 unknown

// 要对 unknown 类型进行属性访问，需要进行类型断言（别急，马上就讲类型断言！），即“虽然这是一个未知的类型，但我跟你保证它在这里就是这个类型！”：
let unknownVar2: unknown = { foo: () => { } };
(unknownVar2 as { foo: () => {} }).foo();
